<template>
  <div>
    <!-- table区域-begin -->
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,onSelect:onSelect,type:'radio'}"
      @change="handleTableChange"
    >
      <template slot="serialNum" slot-scope="text,record,index">
        {{(ipagination.current-1) * ipagination.pageSize + parseInt(index) + 1}}
      </template>

    </a-table>

  </div>
</template>

<script>

  import { YcListMixin } from '@/mixins/YcListMixin'
  import { filterMultiDictText } from '@/components/dict/YchDictSelectUtil'
  import { EFormConstant } from '../../../eform/EFormConstant'
  import YchConstant from "@/api/YchConstant";

  export default {
    name: 'ActAppObjectList',
    mixins: [YcListMixin],
    components: {

    },
    props: {
      groupId: {
        type: String,
        required: true
      },
    },
    data () {
      return {
        queryParam: {
          groupId: this.groupId
        },
        selectedRowKeys: [],
        columns: [
          {
            title:this.$t('m.common.label.number'),
            dataIndex: '',
            key: 'rowIndex',
            width: 50,
            align: 'center',
            scopedSlots: { customRender: 'serialNum' },
          },
          {
            title: this.$t('m.eform.apptable.entity.objName'),
            align: 'center',
            dataIndex: 'objName'
          },
          {
            title: this.$t('m.eform.apptable.entity.objCode'),
            align: 'center',
            dataIndex: 'objCode'
          },
          {
            title: this.$t('m.eform.apptable.entity.objStructure'),
            align: 'center',
            dataIndex: 'objStructure',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(EFormConstant.objStructure, text + '')
              }
            }
          },
        ],
        url: {
          list: YchConstant.PREFIX_EFORM + '/manage/actAppObject/queryByGroupIdPageList',
          delete: YchConstant.PREFIX_EFORM + '/manage/actAppObject/delete',
          deleteBatch: YchConstant.PREFIX_EFORM + '/manage/actAppObject/deleteBatch',
        }
      }
    },

    methods: {
      onSelectChange (selectedRowKeys) {
        this.selectedRowKeys = selectedRowKeys;

      },
      onSelect(record, selected){
        this.$emit("selectErModel",record);
      },
    },
    watch: {
      groupId: {
        immediate: true,
        handler (value) {
          if (value) {
            this.queryParam = {
              groupId: value
            }
            this.loadData()
          } else {
            this.queryParam = {
              groupId: null
            }
            this.dataSource = []
          }
        }
      },

    },
  }
</script>
<style lang="less" scoped>
</style>
